import Vue from 'vue';
import VueRouter from 'vue-router';
const Home = res=> require.ensure([], ()=>res(require('./views/home')),'Home');
const Tab = res=> require.ensure([], ()=>res(require('./views/tab')),'Tab');
const Result = res=> require.ensure([], ()=>res(require('./views/result')),'Result');
// const Share = res=> require.ensure([], ()=>res(require('./views/share')),'Share');

Vue.use(VueRouter)

export default new VueRouter({
  routes: []
    .concat([
      {
        path: '*',
        redirect: '/home',
        name: 'NotFound'
      },
      {
        path:'/home',
        component:Home
      },
      {
        path: '/tab',
        component: Tab
      },
      {
        path: '/result/:type',
        component: Result
      },
      // {
      //   path: '/result/:type',
      //   component: Share
      // },
    ]),
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
